#在pycharm中下载selenium
#下载一个浏览器驱动程序，在网上搜索即可。https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/，需要对应浏览器版本,
# 还需要下载一个pip install msedge-selenium-tools工具


from docutils.nodes import document
from pywin.framework import window
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
import time
import csv
from time import sleep

from selenium.webdriver.common.keys import Keys

# webdriver.edge(executable_path = './msedgedriver.exe')

bro = webdriver.Edge(executable_path = './msedgedriver.exe')
# webdriver.Edge('./地址.exe')
bro.get('https://www.1688.com/')
# bro.find_element(By.)
# input_q = input('输入你想在淘宝搜索的产品:')
sleep(2)
search_input = bro.find_element_by_id('home-header-searchbox')
search_input.send_keys('外套')
#
btn = bro.find_element_by_css_selector('.single')
btn.click()
sleep(2)
# 执行一组js代码
# for i in range(1,5):
btn1 = bro.find_element_by_class_name('baxia-dialog-close')
btn1.click()
sleep(2)
bro.execute_script('window.scrollTo(0,document.body.scrollHeight)')
# btn = bro.find_element_by_class_name('btn-search')
# btn2 = bro.find_element_by_css_selector('.fui-next')

#     btn2 = bro.find_element_by_xpath('/html/body/div[2]/div/div[3]/div[1]/div[1]/div[2]/div[2]/div[1]/div[2]/div[2]/div[8]/div/button[2]')

btn2.click()
sleep(3)



# btn2 = bro.find_element_by_xpath('//div[@next-pagination-list]/button[2]')

# bro.execute_script('window.scrollTo(0,document.body.scrollHeight)')
sleep(0)
bro.quit()






